<template>
  <div class="detail-view">
    <!-- 头部 -->
    <detail-header :title="sightName"></detail-header>
    <!-- 轮播图 -->
    <detail-swiper :title="sightName" :list="swiperList"></detail-swiper>
    <!-- 列表 -->
    <detail-list :title="sightDesc" :list="categoryList"></detail-list>
  </div>
</template>

<script>
import axios from 'axios'
import DetailSwiper from './cpns/DetailSwiper.vue'
import DetailHeader from './cpns/DetailHeader.vue'
import DetailList from './cpns/DetailList.vue'
export default {
  name: 'DetailView',
  components: {
    DetailSwiper,
    DetailHeader,
    DetailList,
  },
  data() {
    return {
      swiperList: [],
      categoryList: [],
      sightName: '',
      sightDesc: '',
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      axios
        .get('/api/detail.json', {
          params: {
            id: this.$route.query.id,
          },
        })
        .then((res) => {
          res = res.data
          if (res.code === 200 && res.data) {
            this.swiperList = res.data.swiperList
            this.categoryList = res.data.categoryList
            this.sightName = res.data.sightName
            this.sightDesc = res.data.sightDesc
          }
        })
    },
  },
}
</script>

<style lang="scss" scoped>
.detail-view {
}
</style>
